package org.zfes.snowier.cloud.zbss.cms.router.service.content;

import java.util.Map;
import java.util.Optional;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.zfes.snowier.core.data.DataSet;
import org.zfes.snowier.web.controller.BaseController;
import org.zfes.snowier.cloud.zbss.cms.content.model.CmsContentAttachment;
import org.zfes.snowier.cloud.zbss.cms.content.service.ICmsContentAttachmentService;
@Controller("org.zfes.snowier.cloud.zbss.cms.router.service.content.CmsContentUserDefineAttrController") 
@RequestMapping("/cms/service/content/cmsContentAttachment")
public class CmsContentAttachmentController extends BaseController {

	
	@Autowired
	private ICmsContentAttachmentService cmsContentAttachmentService;
	
	@RequiresPermissions(value="cmsContentAttachment:loadCmsContentAttachmentDataSet",desc="附件列表")
    @RequestMapping(value="/loadCmsContentAttachmentDataSet", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object loadCmsContentAttachmentDataSet(@RequestParam Map<String,Object> params){
	    DataSet dataSet=  cmsContentAttachmentService.loadCmsContentAttachmentDataSet(params);
	    return ajaxQuery("dataSet", dataSet);
    }
	
	@RequiresPermissions(value="cmsContentAttachment:createCmsContentAttachment",desc="附件添加")
    @RequestMapping(value="/createCmsContentAttachment", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public  @ResponseBody Object createCmsContentAttachment(CmsContentAttachment cmsContentAttachment){
		cmsContentAttachmentService.createCmsContentAttachment(cmsContentAttachment);
    	return ajaxDoneSuccess("数据操作成功 ");
    }
	
	@RequiresPermissions(value="cmsContentAttachment:loadCmsContentAttachment",desc="附件加载")
    @RequestMapping(value="/loadCmsContentAttachment", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object loadCmsContentAttachment(Long id){
		Optional<CmsContentAttachment> ops = cmsContentAttachmentService.loadCmsContentAttachmentById(id);
		return ajaxQuery("cmsContentAttachment",ops);
    }
	
	@RequiresPermissions(value="cmsContentAttachment:updateCmsContentAttachment",desc="附件更新")
    @RequestMapping(value="/updateCmsContentAttachment", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object updateCmsContentAttachment(CmsContentAttachment cmsContentAttachment){
		cmsContentAttachmentService.updateCmsContentAttachment(cmsContentAttachment);
		return ajaxDoneSuccess("数据操作成功 ");
    }
	
	@RequiresPermissions(value="cmsContentAttachment:deletCmsContentAttachment",desc="附件删除")
    @RequestMapping(value="/deleteCmsContentAttachment", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object deleteCmsContentAttachment(Long id){
		cmsContentAttachmentService.deleteCmsContentAttachment(id);
		return ajaxDoneSuccess("数据操作成功 ");
    }

}